package com.tiantian.system.dubbo;

import cn.hutool.core.bean.BeanUtil;
import com.tiantian.api.RemoteLogService;
import com.tiantian.api.domain.bo.RemoteLogininforBo;
import com.tiantian.api.domain.bo.RemoteOperLogBo;
import com.tiantian.system.domain.bo.SysLogininforBo;
import com.tiantian.system.domain.entity.SysOperLog;
import com.tiantian.system.service.SysLogininforService;
import com.tiantian.system.service.SysOperLogService;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

/**
 * 操作日志记录
 *
 * @author Lion Li
 */
@RequiredArgsConstructor
@Service
@DubboService
public class RemoteLogServiceImpl implements RemoteLogService {

    private final SysOperLogService operLogService;
    private final SysLogininforService logininforService;

    @Override
    public void saveLog(RemoteOperLogBo remoteOperLogBo) {
        SysOperLog sysOperLog = BeanUtil.copyProperties(remoteOperLogBo, SysOperLog.class);
        operLogService.insertOperLog(sysOperLog);
    }

    @Override
    public void saveLogininfor(RemoteLogininforBo remoteLogininforBo) {
        SysLogininforBo sysLogininforBo = BeanUtil.copyProperties(remoteLogininforBo, SysLogininforBo.class);
        logininforService.insertLogininfor(sysLogininforBo);
    }
}
